//
// Created by liushuai on 2021/1/24.
//

#include "lengthOfLIS.h"

int lengthOfLIS(vector<int> &nums) {

    if (nums.empty())
        return 0;
    vector<int> DP = vector<int>(nums.size(), 0);
    DP[0] = 1;
    int max_size = 1;
    for (int i = 1; i < nums.size(); i++) {
        DP[i] = 1;//防止i=1的时候计算DP
        for (int j = 0; j < i; j++) {
            if (nums[i] > nums[j]) {
                DP[i] = max(DP[j] + 1, DP[i]);// 找到最大组合
            }
        }

        max_size = max(max_size, DP[i]);

    }
    return max_size;
}